package com.fattyCorps.controller;

import com.fattyCorps.obj.msg.SRet;
import com.fattyCorps.service.GachaService;
import com.fattyCorps.utils.ServletUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/gacha")
public class GachaController {

    @Autowired
    GachaService gachaService;

    @PostMapping("/getGachaInfo")
    public SRet getGachaInfo(HttpServletRequest request){
        Integer playerId = ServletUtils.getPlayerIdByRequest(request);
        SRet ret = gachaService.getGachaInfo(playerId);
        return ret;
    }

    @PostMapping("/freeRoll")
    public SRet freeRoll(HttpServletRequest request){
        Integer playerId = ServletUtils.getPlayerIdByRequest(request);
        SRet ret = gachaService.freeRoll(playerId);
        return ret;
    }

    @PostMapping("/oneCoinRoll")
    public SRet oneCoinRoll(HttpServletRequest request){
        Integer playerId = ServletUtils.getPlayerIdByRequest(request);
        SRet ret = gachaService.oneCoinRoll(playerId);
        return ret;
    }

    @PostMapping("/tenCoinRolls")
    public SRet tenCoinRolls(HttpServletRequest request){
        Integer playerId = ServletUtils.getPlayerIdByRequest(request);
        SRet ret = gachaService.tenCoinRolls(playerId);
        return ret;
    }

}
